/* GUI CONVERTED from rcshwcar.p (converter v1.75) Sat Aug 12 23:02:42 2000 */
/* rcshwcar.p - Shipping WorkBench Carrier Details                           */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                       */
/* All rights reserved worldwide.  This is an unpublished work.              */
/*V8:ConvertMode=Maintenance                                                 */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                      */
/* REVISION: 8.6            CREATED: 07/26/96   BY: *K003* Vinay Nayak-Sujir */
/* REVISION: 8.6      LAST MODIFIED: 03/15/97   BY: *K04X* Steve Goeke       */


/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                 */
         /* DISPLAY TITLE */
         {mfdeclre.i}
{gplabel.i} /* EXTERNAL LABEL INCLUDE */

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rcshwcar_p_1 "Seq"
/* MaxLen: Comment: */

&SCOPED-DEFINE rcshwcar_p_2 " Carriers "
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define input parameter absid like abs_id no-undo.
         define input parameter height-chars as integer no-undo.

         define variable seq            like absc_seq no-undo.
         define variable seq_str        as character format "x(3)" no-undo.

         define variable absc_recno     as recid no-undo.
         define variable i              as integer no-undo.
         define variable del-yn         like mfc_logical no-undo.

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            space  (1)
            seq
            absc_carrier
            ad_name
         with frame a width 80 no-underline  THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         FORM /*GUI*/ 
            space  (1)
            seq_str label {&rcshwcar_p_1}
            absc_carrier
            ad_name
         with frame c width 80 no-underline title color normal
         (getFrameTitle("CARRIERS",13)) THREE-D /*GUI*/.


         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c:handle).

         pause 0.
         view frame c.
         view frame a.

         browloop:
         repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


            if can-find (first absc_det where absc_abs_id = absid)
               then do with frame c:
               /* Display records on the browse portion of the frame */
               {swindar.i
                  &searchkey = absid
                  &detfile = absc_det
                  &detkey  = absc_abs_id
                  &detlink = absc_carrier
                  &mstrfile = ad_mstr
                  &mstrkey  = ad_addr
                  &scroll-field = seq_str
                  &framename = "c"
                  &framesize = height-chars
                  &display1 = "string(absc_seq,'>>9') @ seq_str"
                  &display2 = absc_carrier
                  &display3 = "ad_name when (available ad_mstr)"
                  &exitlabel = browloop
                  &exit-flag = false
                  &record-id = absc_recno
               }
            end.

            setloop:
            repeat on endkey undo setloop, leave setloop with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

               view.
               clear frame c all no-pause.
               find absc_det where recid(absc_det) = absc_recno
                    no-lock no-error.
               if available absc_det then do:
                  do i = 1 to truncate(frame-down(c) / 2,0)
                     while available absc_det:
                     find next absc_det where
                          absc_abs_id = absid no-lock no-error.
                  end.
                  if not available absc_det then do:
                     find last absc_det where
                          absc_abs_id = absid no-lock no-error.
                  end.
                  do i = 1 to frame-down(c) - 1 while available absc_det:
                     find prev absc_det where
                          absc_abs_id = absid no-lock no-error.
                  end.
                  if not available absc_det then do:
                     find first absc_det where
                          absc_abs_id = absid no-lock no-error.
                  end.
               end.
               else do:
                  find first absc_det where
                       absc_abs_id = absid no-lock no-error.
               end.

               if available absc_det then do:
                  do i = 1 to frame-down(c) while available absc_det:
                     find ad_mstr where ad_addr = absc_carrier no-lock no-error.
                     display string(absc_seq,">>9") @ seq_str absc_carrier
                        ad_name when (available ad_mstr) with frame c.

                     find next absc_det where
                          absc_abs_id = absid no-lock no-error.

                     if frame-line(c) < frame-down(c) then down 1 with frame c.
                  end.
               end.

               find absc_det where recid(absc_det) = absc_recno
                    no-lock no-error.
               if not available absc_det then
                  find first absc_det where
                       absc_abs_id = absid no-lock no-error.

/*K04X*/       keyblk:
/*K04X*/       do on error undo , retry:
/*GUI*/ if global-beam-me-up then undo, leave.


                  if available absc_det then do:
                     find ad_mstr where ad_addr = absc_carrier no-lock no-error.
                     assign seq = absc_seq.
                     display seq absc_carrier ad_name when (available ad_mstr).
                  end.

/*K04X*           keyblk:
 *K04X*           do on error undo , retry:
 *K04X*/
                  update seq editing:
                     {mfnp01.i absc_det seq absc_seq
                               absid absc_abs_id absc_abs_id}
                     if recno <> ? then do:
                        find ad_mstr where ad_addr = absc_carrier
                             no-lock no-error.
                        assign seq = absc_seq.
                        display seq absc_carrier
                                ad_name when (available ad_mstr).
                     end.
                  end. /* update addr */

                  if seq = 0 then do:
                     {mfmsg.i 5841 3}
                     /* SEQUENCE NUMBER CANNOT BE 0 */
                     next-prompt seq.
                     undo keyblk, retry keyblk.
                  end.

                  find absc_det where
                       absc_abs_id = absid and
                       absc_seq    = seq
                  exclusive-lock no-error.

                  if not available absc_det then do:
                     {mfmsg.i 1 1}
                     /* ADDING NEW RECORD */
                     create absc_det.
                     assign
                        absc_abs_id = absid
                        absc_seq    = seq.
                  end.

                  find ad_mstr where ad_addr = absc_carrier
                       no-lock no-error.
                  display absc_carrier
                          (if available ad_mstr then ad_name else "") @ ad_name.

                  assign absc_recno = recid(absc_det).
/*K04X*           status input stline[2].  *K04X*/

                  attrblk:
                  do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

                     set absc_carrier go-on ("F5" "CTRL-D")
/*K04X*/             editing:

/*K04X*/                /* Carrier address field */
/*K04X*/                if frame-field eq "absc_carrier" then do:
/*K04X*/                   {mfnp05.i
                              ad_mstr
                              ad_addr
                              "(ad_type eq 'carrier' or
                                can-find
                                   (ls_mstr where
                                      ls_type eq 'carrier' and
                                      ls_addr eq ad_addr))"
                              ad_addr
                              "input frame a absc_carrier"
                              stline[2] }
/*K04X*/                   if recno ne ? then
/*K04X*/                      display
/*K04X*/                         ad_addr @ absc_carrier
/*K04X*/                         ad_name.
/*K04X*/                end.  /* if frame-field eq "absc_carrier" */

/*K04X*/                /* Any other field */
/*K04X*/                else do:
/*K04X*/                   readkey.
/*K04X*/                   apply lastkey.
/*K04X*/                end.  /* else */

/*K04X*/             end.  /* editing */

                     if lastkey = keycode("F5")
                     or lastkey = keycode("CTRL-D") then do:
                        del-yn = yes.
                        {mfmsg01.i 11 1 del-yn}
                        if del-yn = no then undo keyblk , retry keyblk.
                        delete absc_det.
                        find next absc_det where
                             absc_abs_id = absid no-lock no-error.
                        if not available absc_det then
                           find prev absc_det where
                                absc_abs_id = absid no-lock no-error.
                        if not available absc_det then
                           find first absc_det where
                                absc_abs_id = absid no-lock no-error.

                        absc_recno = ?.
                        if available absc_det then
                           absc_recno = recid(absc_det).
                        next setloop.
                     end.

                     if not can-find (first ad_mstr where
                                            ad_addr = absc_carrier) then do:
                        {mfmsg.i 980 3}
                        /* ADDRESS DOES NOT EXIST  */
                        next-prompt absc_carrier.
                        undo attrblk, retry attrblk.
                     end.

                     if not can-find (first ls_mstr where
                                            ls_addr = absc_carrier and
                                            ls_type = "carrier" ) then do:
                        {mfmsg.i 5905 3}
                        /* ADDRESS IS NOT OF TYPE "CARRIER" */
                        next-prompt absc_carrier.
                        undo attrblk, retry attrblk.
                     end. /* not can-find ls_mstr  */

                     find ad_mstr where ad_addr = absc_carrier no-lock no-error.
                     display ad_name when (available ad_mstr).

                  end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* attrblk */
               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* keyblk */
            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* setloop */

            if keyfunction(lastkey) = "end-error"  then
               if can-find (first absc_det where absc_abs_id = absid) then
                  next browloop.
               else
                  leave browloop.

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* browloop */

         pause 0.
         hide frame c.
         hide frame a.
